import * as THREE from 'three';
import Scene from '../Scene';
import Room from './Room';
import BakeModel from './BakeTest';
import TubeMesh from './TubeMesh';
import UVTest from './UVTest';
import Light from './Light';
import Controls from './Controls';


export default class World {
    constructor(){
        console.log('World render');
        this.scene = new Scene();
        this.sizes = this.scene.sizes;
        this.canvasScene = this.scene.scene;
        this.canvas = this.scene.canvas;
        this.resources = this.scene.resources;
        this.resources.on('ready',()=>{
            // this.model = new BakeModel();
            this.light = new Light();
            this.model = new Room();
            // 添加世界坐标系
            // let axesHelper = new THREE.AxesHelper(12);
            // this.canvasScene.add(axesHelper);
            // 添加网格辅助线
            // let grid = new THREE.GridHelper(50, 50, 0x555555, 0x444444 );
            // grid.material.opacity = 0.5;
            // grid.material.transparent = true;
            // this.canvasScene.add(grid);
            // console.log(boxMesh);
            // console.log(boxMesh.geometry.attributes.position.getX(1), boxMesh.geometry.attributes.position.getY(1), boxMesh.geometry.attributes.position.getZ(1));
            // console.log(boxMesh.geometry.index.getX(1), boxMesh.geometry.index.getZ(2), boxMesh.geometry.index.getX(6));
            // this.controls = new Controls();
        })
    }
    update(){
        if ( this.room ){
            this.room.update();
        }
        if ( this.controls ) {
            this.controls.update();
        }
        if ( this.model ) {
            this.model.update();
        }
    }
}